Search libraries in KDEINIT5_LIBRARY_PATH.

Based on an idea by NixOs
pkgs/development/libraries/kde-frameworks/kinit/kinit-libpath.patch

===================================================================
diff --git a/src/kdeinit/kinit.cpp b/src/kdeinit/kinit.cpp
--- a/src/kdeinit/kinit.cpp
+++ b/src/kdeinit/kinit.cpp
@@ -614,15 +614,12 @@ static pid_t launch(int argc, const char *_name, const char *args,
                 //     RUNPATH of kdeinit is *not* respected - see
                 //     https://sourceware.org/bugzilla/show_bug.cgi?id=13945
                 //     - so we try hacking it in ourselves
-                QString install_lib_dir = QFile::decodeName(
-                        CMAKE_INSTALL_PREFIX "/" KDE_INSTALL_LIBDIR "/");
-                QString orig_libpath = libpath;
-                libpath = install_lib_dir + libpath;
-                l.setFileName(libpath);
-                if (!l.load()) {
-                    libpath = orig_libpath;
-                    l.setFileName(libpath);
-                    l.load();
+                QByteArrayList profiles = qgetenv("KDEINIT5_LIBRARY_PATH").split(':');
+                for (const QByteArray &profile: profiles) {
+                    if (!profile.isEmpty()) {
+                        l.setFileName(QFile::decodeName(profile) + QStringLiteral("/") + libpath);
+                        if (l.load()) break;
+                    }
                 }
             } else {
                 l.load();
-- 
2.33.0

